package com.zhuozhengsoft.pageoffice6springboot2back.controller;

import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.word.DataRegionWriter;
import com.zhuozhengsoft.pageoffice.word.WordDocumentWriter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/DataRegionFill")
public class DataRegionFillController {

    @RequestMapping(value = "/Word")
    public String showWord(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);

        WordDocumentWriter doc = new WordDocumentWriter();
        //打开数据区域
        DataRegionWriter dataRegion1 = doc.openDataRegion("PO_userName");
        //给数据区域赋值
        dataRegion1.setValue("张三");

        DataRegionWriter dataRegion2 = doc.openDataRegion("PO_deptName");
        dataRegion2.setValue("销售部");

        poCtrl.setWriter(doc);
        //打开文档
        poCtrl.webOpen("/doc/DataRegionFill/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }


}
